Skip to content

Conversation

@AtofStryker
Copy link
Contributor

@AtofStryker AtofStryker commented Oct 9, 2025

  • Closes

Additional details

With the changes to @packages/socket, @packages/extension needs to be able to have a test environment that better supports ESM. To do that, this PR migrates @packages/extension to TypeScript and Vitest. The extension is now bundled slightly different than before. This is now lined out in the README.md:

@packages/extension has a few different build processes occurring that are all driven by the gulpfile.

  • app - The web extension piece of the code, has two separate bundles:
    • v2: Version 2 of the web extension which uses webpack to bundle the app/v2 directory and output it as background.js
    • v3: Version 3 of the web extension, which doesn't have any external dependencies so we are able to compile down to `ESM to run in the browser natively.
  • lib - the @packages/extension main entry that has utility methods on how to find/load the extension. This is transpiled to CommonJS as it is consumed in the Node context.

The lib section now ships with declarations compiled since the move to TypeScript, hence why we awere able to remove the old declarations and entry.

Outside of this, I moved a few files around as we are still dealing with circular dependencies.

  • correctly references errors.clone inside @packages/proxy. before it was referencing the server and creating a circular reference (cookie automation circular references still remain)
  • removes the @packages/extension dependency from the automation cookie logic and move the getCookieUrl function into the automation client as it isn't used anywhere else. Eventually, the cookie automation logic will be extracted out of the server, likely to network-tools or something adjacent.

Steps to test

Everything should behave the same. If running locally, you likely want to run a git clean -fxd and reinstall dependencies to see the appropriate build folders. Follow the steps to debug the extension in the readme

How has the user experience changed?

PR Tasks


Note

Migrates @packages/extension to TS/ESM with Vitest, introduces new app/lib build outputs, updates webpack/gulp, replaces legacy tests, and adjusts server/proxy imports and cookie URL logic.

  • @packages/extension (TS/ESM + build refactor):
    • Convert app/v2 and app/v3 code to TypeScript/ESM; replace CommonJS requires; add typings for webextension APIs.
    • New build outputs: app-dist/ (extension) and lib-dist/ (Node lib); update paths in helpers; add .gitignore for these.
    • Replace webpack entry with init.ts; add webpack.config.mjs (TS-loader w/ tsconfig.app.v2.json).
    • Revamp gulpfile.ts: switch to building v2/v3/lib via yarn scripts; copy assets to app-dist; get icons/logos from @packages/icons.
    • Update package.json: main -> lib-dist/index.js, add build scripts (build:v2, build:v3, build:lib), switch tests to vitest, add deps (vitest, webpack-cli, @types/webextension-polyfill).
    • Remove old JS entry/types (index.js, index.d.ts, lib/extension.js, lib/util.js); add lib/index.ts replacement and TS configs (tsconfig.*).
    • Tests: migrate Mocha/Sinon/Chai specs to Vitest TS (*.spec.ts), delete legacy JS specs and mocha setup; add vitest.config.ts.
    • README: document new build/watch/test flows and app/lib bundling.
  • WebExtension runtime changes:
    • app/v2/background.ts, client.ts, init.ts: typed APIs, import Bluebird, export automation.
    • app/v3/content.ts and service-worker.ts: add TypeScript annotations and stricter message handling.
  • Server/Proxy adjustments:
    • Move cookie URL helper into server/lib/automation/cookies.ts and use there; drop dependency on @packages/extension for cookies.
    • Update Chrome integration to import * as extension for path helpers.
    • Proxy error middleware now imports from @packages/errors.
  • CI/Docs:
    • CircleCI: adjust expectedResultCount from 5 to 4 in unit-tests step.
    • Guides: mark packages/extension as completed in ESM migration checklist.
    • Tests referencing extension paths updated from dist/ to app-dist/.

Written by Cursor Bugbot for commit 30bd3fc. This will update automatically on new commits. Configure here.

cursor[bot]

This comment was marked as outdated.

@cypress
Copy link

cypress bot commented Oct 9, 2025

cypress    Run #66742

Run Properties:  status check passed Passed #66742  •  git commit 30bd3fc5e0: chore: typecheck the whole package
Project cypress
Branch Review chore/extension_migration
Run status status check passed Passed #66742
Run duration 19m 07s
Commit git commit 30bd3fc5e0: chore: typecheck the whole package
Committer Bill Glesias
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 13
Tests that did not run due to a developer annotating a test with .skip  Pending 1102
Tests that did not run due to a failure in a mocha hook  Skipped 4
Tests that passed  Passing 26730
View all changes introduced in this branch ↗︎

Warning

Partial Report: The results for the Application Quality reports may be incomplete.

UI Coverage  45.56%
  Untested elements 185  
  Tested elements 159  
Accessibility  97.97%
  Failed rules  4 critical   8 serious   2 moderate   2 minor
  Failed elements 101  

@AtofStryker AtofStryker force-pushed the chore/extension_migration branch from 6772100 to a3e39ab Compare October 15, 2025 19:33
@AtofStryker AtofStryker changed the base branch from develop to chore/refactor-socket-and-extension October 15, 2025 19:33
@AtofStryker AtofStryker force-pushed the chore/extension_migration branch from a3e39ab to 8b308cd Compare October 15, 2025 19:37
@AtofStryker AtofStryker self-assigned this Oct 15, 2025
@AtofStryker AtofStryker force-pushed the chore/extension_migration branch from 8b308cd to c7c22b2 Compare October 16, 2025 01:48
cursor[bot]

This comment was marked as outdated.

@AtofStryker AtofStryker force-pushed the chore/extension_migration branch from c7c22b2 to 6a699b9 Compare October 16, 2025 14:28
cursor[bot]

This comment was marked as outdated.

@AtofStryker AtofStryker force-pushed the chore/extension_migration branch from 6a699b9 to 7a1c3de Compare October 16, 2025 15:32
@AtofStryker AtofStryker changed the base branch from chore/refactor-socket-and-extension to chore/refactor-socket October 16, 2025 15:32
@@ -1,10 +0,0 @@
module.exports = {
getCookieUrl: (cookie = {}) => {
const prefix = cookie.secure ? 'https://' : 'http://'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved into the automation cookie code in the server as it is the only place its used

@AtofStryker AtofStryker force-pushed the chore/extension_migration branch from 7a1c3de to 73dac30 Compare October 16, 2025 17:44
@AtofStryker AtofStryker changed the title chore (draft): migrate extension to typescript and tests to vitest chore: migrate @packages/extension to TypeScript and tests to Vitest Oct 16, 2025
@AtofStryker AtofStryker force-pushed the chore/extension_migration branch from 73dac30 to 64d76a8 Compare October 16, 2025 18:06
Base automatically changed from chore/refactor-socket to chore/refactor-socket-and-extension October 16, 2025 22:01
@AtofStryker AtofStryker force-pushed the chore/extension_migration branch from 64d76a8 to de94f36 Compare October 16, 2025 22:08
@AtofStryker AtofStryker force-pushed the chore/extension_migration branch from de94f36 to 6ecc170 Compare October 17, 2025 01:13
@AtofStryker AtofStryker force-pushed the chore/extension_migration branch from 6ecc170 to 476783e Compare October 21, 2025 01:19
@jennifer-shehane jennifer-shehane self-requested a review October 21, 2025 20:00
Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of tests that just assert some function to not be called, but no other positive assertion in the test - like these tests would also pass if we just broke the implementation. I know it's just transferring what we currently have, but that made me a bit nervous during review.


return prefix + host + (cookie.path || '')
}

Copy link
Member

@jennifer-shehane jennifer-shehane Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AtofStryker I know this is not meant to be a refactor, but this note from CursorBot is interesting.

@AtofStryker
Copy link
Contributor Author

There's a lot of tests that just assert some function to not be called, but no other positive assertion in the test - like these tests would also pass if we just broke the implementation. I know it's just transferring what we currently have, but that made me a bit nervous during review.

@jennifer-shehane can you elaborate on which positive assertion calls are missing? I feel like we have pretty good coverage on the v2 background and v3 service-worker/content code where we are asserting the expected positive condition, but in some cases we are testing a lot of no-op scenarios in addition to these. At least at a glance things looks well tested

Eventually we can start getting some v8 code coverage reports as well once we get closer to having some type of test unification
Screenshot 2025-10-22 at 3 30 47 PM

@jennifer-shehane
Copy link
Member

@AtofStryker Yah, it's a lot of noop situations basically is what I was pointing out.

@AtofStryker
Copy link
Contributor Author

@AtofStryker Yah, it's a lot of noop situations basically is what I was pointing out.

@jennifer-shehane I think thats fair. It's a bit bizarre but understandable because there is really one happy path and 4-5 other not happy paths so there are a lot of unit tests for the not happy path

@AtofStryker AtofStryker merged commit 50ceb5a into chore/refactor-socket-and-extension Oct 23, 2025
83 of 88 checks passed
@AtofStryker AtofStryker deleted the chore/extension_migration branch October 23, 2025 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants